package com.smiletrain.view;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;

import com.smiletrain.R;
import com.smiletrain.activities.CasoActivity;
import com.smiletrain.util.AdminCasos;

public class ItemCaso {

	public ItemCaso(int id, String text) {
		this.setId(id);
		this.text = text;
	}

	public void generateView(final ViewGroup parent) {
		View rview = LayoutInflater.from(parent.getContext())
        		.inflate(R.layout.itemcaso, null);
        TextView title = (TextView) rview.findViewById(R.id.titulo);  
        title.setText(text);
        title.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				AdminCasos.instance.setCasoActual(id);
				Intent intent = new Intent(parent.getContext(), CasoActivity.class);
				parent.getContext().startActivity(intent);
			}
		});
        
        view = rview;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	public String getText() {
		return text;
	}
	
	public void setText(String text) {
		this.text = text;
	}

	public View getView() {
		return view;
	}

	public void setView(View view) {
		this.view = view;
	}

	private int id = 0;
	private String text = "";
	private View view = null;
	
}
